# 导包
import requests

# 发送获取验证码请求
response = requests.get(url="http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg")
print("获取验证码的结果为：", response.content)

# 提取cookie
cookie = response.cookies

# 发送注册请求
response = requests.post(url="http://tpshop-test.itheima.net/Home/User/reg.html",
                         headers={"Content-Type":"application/x-www-form-urlencoded"},
                         data={"scene":"1",
                               "username":"13822338006",
                               "verify_code":"8888",
                               "password":"123456",
                               "password2":"123456",
                               "invite":""},
                         cookies=cookie)
# 打印响应结果
print("注册的结果为：", response.json())